package cn.zhou.web.controller;

import cn.zhou.domain.Account;
import cn.zhou.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @author zy9524
 * @date 2019/6/9 14:39
 */
@Controller
public class AccountController {

    @Autowired
    private AccountService accountService;

    @RequestMapping("/findAllAccount")
    public ModelAndView findAllAccount(ModelAndView modelAndView){
        List<Account> accountList= accountService.findAllAcount();
        modelAndView.addObject("accountList", accountList);
        modelAndView.setViewName("home");
        return modelAndView;
    }

    @RequestMapping("/transMoney")
    public String transMoney(String fromName,String toName, Float money){
        accountService.transMoney(fromName,toName,money );
        return  "success";
    }

}
